<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body,
        html {
            width: 100%;
            height: 100%;
        }

        .box {
            width: 300px;
            height: 600px;
            margin: auto;
            text-align: center;
        }

        #odiv {
            width: 200px;
            height: 200px;
            margin: auto;
            background-color: black;
            padding: 10px 10px;
            color: white;
        }
    </style>
</head>

<body>
    <div class="box">
        属性名：<input type="text" value="background"><br>
        属性值：<input type="text" value="black">
        <p><button id="yes">确定</button> <button id="reset">重置</button></p>
        <div id="odiv">在上方输入框输入"属性名"及"属性值"，点击确定按钮查看效果。</div>
    </div>
</body>
<script>
    var change = function (a, b, c) {
        a.style[b] = c
    }

    window.onload = function () {
        var oinput = document.getElementsByTagName('input')
        var oyes = document.getElementById('yes')
        var oreset = document.getElementById('reset')
        var odiv = document.getElementById('odiv')

        oyes.onclick = function(){
            var x = oinput[0].value
            var y = oinput[1].value

           change(odiv,x,y)

        }

        oreset.onclick = function(){
            odiv.style.cssText = ''
        }
    }
</script>

</html>